package com.studyyang.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * RabbitMq连接工具类
 *
 * @Author yangjin
 * @Description
 * @Date 2021/10/28/21:33
 **/
public class RabbitmqUtils {
    private static ConnectionFactory factory = new ConnectionFactory();
    static {
        //ConnectionFactory用于创建MQ的物理连接
        factory.setHost("81.70.239.179");
        factory.setPort(5672);
        factory.setUsername("admin");
        factory.setPassword("admin");
        factory.setVirtualHost("admin");
    }

    public static Connection getRabbitMqConn(){
        try {
            return factory.newConnection();
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
}
